<?php

namespace app\common\model;

//use think\Model;

class UserRecoveryModel extends BaseModel {

	protected $table = 'tp_user_recovery';


	public function setWords($uid,$words,$password='',$address){
		$res = $this->insert([
			'uid'=>$uid,
			'words' =>$words,
			'keystore'=>'{"address":"'.$address.'","id":"'.md5($uid).'","mnemonicCiphertext":"'.md5($words).'","path":"m/"'.$uid.'"/60/0/0/0","version":"0.1"}',
			'private_key'=>$uid.md5($words),
			'password'=>md5($password),
			'status'=>0
		]);
		return $res;
	}

	public function getKeystore($password){
		return $password;
	}

	public function getWords($uid){
		
		$data = $this->where('uid',$uid)->find();
		return $data;
	}

	public function checkWords($words){
		$data = $this->where('words',$words)->find();
		return $data;
	}

	public  function copyWords($uid){
		$res = $this->where('uid',$uid)->update([
			'status'=>1
		]);
		return $res;
	}
}